package com.monkeygroup.mygoplus.view.home.activity.person;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;

import com.monkeygroup.mygoplus.R;
import com.monkeygroup.mygoplus.base.BaseActivity;
import com.monkeygroup.mygoplus.view.home.activity.PublishedSecondActivity;
import com.monkeygroup.mygoplus.view.home.activity.PublishedThirdActivity;
import com.monkeygroup.mygoplus.view.home.activity.rent.PublishedRentActivity;
import com.monkeygroup.mygoplus.view.home.activity.rent.PublishedRentLandAcitivity;
import com.monkeygroup.mygoplus.view.home.activity.rent.PublishedRentOfficeActivity;
import com.monkeygroup.mygoplus.view.home.activity.rent.PublishedRentShopAcitivity;
import com.monkeygroup.mygoplus.view.home.activity.sell.PublishedActivity;
import com.monkeygroup.mygoplus.view.home.activity.sell.PublishedLandActivity;
import com.monkeygroup.mygoplus.view.home.activity.sell.PublishedShopActivity;

import java.util.ArrayList;
import java.util.List;

/**
 * 选择身份类型
 * Created by cumt on 2017/6/20.
 */

public class ApplyIdentifyChooseActivity extends BaseActivity implements View.OnClickListener {

    public static void gotoActivity(Activity activity,String type) {
        Intent intent = new Intent(activity,
                ApplyIdentifyChooseActivity.class);
        intent.putExtra("type",type);
        activity.startActivity(intent);
    }

    private ImageView imgBack;
    private TextView txtTitle;

    private ListView publishList;
    private List<String> leftListItems;

    private LeftAdapter adapter;
    private String type;

    @Override
    public void onClick(View v) {

    }

    @Override
    public void setContentView() {
        setContentView(R.layout.published_second);
    }

    @Override
    public void initView() {

        publishList= (ListView)findViewById(R.id.publish_list);

        leftListItems = new ArrayList<String>();

        imgBack = (ImageView) findViewById(R.id.img_back);
        txtTitle = (TextView) findViewById(R.id.txt_title);


        adapter = new LeftAdapter(ApplyIdentifyChooseActivity.this);
        publishList.setAdapter(adapter);

        Intent intent = this.getIntent();
        Bundle bundle =  intent.getExtras();
        type = bundle.getString("type");


        fillData(type);


    }

    private void fillData(String type){

        //专家
        if("1".equals(type)){
            txtTitle.setText("专家");
            leftListItems.add("估價師");
            leftListItems.add("建築設計");
            leftListItems.add("室內設計");
            leftListItems.add("風水師");
            leftListItems.add("市場趨勢");
            leftListItems.add("律師");
            leftListItems.add("會計");
            leftListItems.add("其他");


        }
        else if("2".equals(type)){

            txtTitle.setText("企業品牌");
            leftListItems.add("房仲");
            leftListItems.add("包租");
            leftListItems.add("資產管理");
            leftListItems.add("建設公司");
            leftListItems.add("代銷公司");
            leftListItems.add("設計裝潢");
            leftListItems.add("工程施工");
            leftListItems.add("搬家公司");

        }

    }

    @Override
    public void setListener() {

    }

    @Override
    public void doEvent() {

    }

    public class LeftAdapter extends BaseAdapter {


        private LayoutInflater mInflater;


        public LeftAdapter(Context context){
            this.mInflater = LayoutInflater.from(context);
        }

        @Override
        public int getCount() {
            return leftListItems.size();
        }

        @Override
        public Object getItem(int position) {
            return leftListItems.get(position);
        }

        @Override
        public long getItemId(int position) {
            return position;
        }

        @Override
        public View getView(final int position, View myconvertView, ViewGroup parent) {

            View leftconvertView = mInflater.inflate(R.layout.published_second_item, null);
            final String obj = leftListItems.get(position);
            final TextView txtName = (TextView) leftconvertView
                    .findViewById(R.id.txt_publish_content);
            txtName.setText(obj);


            leftconvertView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Log.e("positionposition==",""+position);
                    ApplyIdentifyActivity.gotoActivity(ApplyIdentifyChooseActivity.this,type,position);


                }
            });

            return leftconvertView;
        }



    }







}
